package com.itheima.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 封装返回结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    private boolean flag;//执行结果，true为执行成功 false为执行失败
    private String message;//返回结果信息
    private Object data;//返回数据

    public static Result success(Object data,String message){
        Result result = new Result();
        result.setFlag(true);
        result.setData(data);
        result.setMessage(message);
        return result;
    }

    public static Result success(String message){
        Result result = new Result();
        result.setFlag(true);
        result.setMessage(message);
        return result;
    }

    public static Result error(String message){
        Result result = new Result();
        result.setFlag(false);
        result.setMessage(message);
        return result;
    }
}
